package org.example.teachermall04.service.admin;

import org.example.teachermall04.entity.Admin;
import org.example.teachermall04.mapper.AdminMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

@Service("adminserviceimpl")
public class AdminServiceimpl implements AdminService {

    @Autowired
    private AdminMapper adminMapper;
    @Override
    public Admin login(String account, String password) {
        Admin admin = adminMapper.getAdminByAccount(account);
        //判断密码是否一致
        //MD5加密
        if(admin!=null){
            boolean isRight = admin.getPassword().equals(DigestUtils.md5DigestAsHex(password.getBytes()));
            if(isRight){
                return admin;
            }else{
                return null;
            }
        }else {
            return null;
        }
    }
}
